Skip to content

Add multisite network checks for site count, network options, and required plugins#208

Open
deshabhishek007 wants to merge 3 commits intowp-cli:mainfrom
deshabhishek007:main
Open

Add multisite network checks for site count, network options, and required plugins#208
deshabhishek007 wants to merge 3 commits intowp-cli:mainfrom
deshabhishek007:main

Conversation

@deshabhishek007
Copy link

Summary

This PR adds three multisite-focused doctor checks with Behat coverage:

  1. Network_Site_Count
    Checks network site count against configurable minimum/maximum thresholds.

  2. Network_Site_Option_Value
    Validates network-level options via get_site_option() using value or value_is_not.

  3. Network_Required_Plugins
    Ensures required plugins are installed and network-activated (active-network).

Why

wp doctor had limited network-specific diagnostics. These checks add practical multisite health/compliance coverage for common ops requirements.

Changes

  • Added:
    • src/Check/Network_Site_Count.php
    • src/Check/Network_Site_Option_Value.php
    • src/Check/Network_Required_Plugins.php
  • Added Behat features:
    • features/check-network-site-count.feature
    • features/check-network-site-option-value.feature
    • features/check-network-required-plugins.feature
  • Added PHP 8.5 compatibility guard in list reflection flow:
    • src/Command.php (ReflectionProperty::setAccessible() guarded for < PHP 8.1)

Behavior Notes

  • All three checks return success with a “check skipped” message on non-multisite installs.
  • Network_Site_Option_Value errors if both value and value_is_not are set.
  • Network_Required_Plugins reports missing and non-network-activated plugins with details.

Testing

  • composer phpcs
  • WP_CLI_TEST_DBTYPE=sqlite composer test
  • Targeted Behat:
    • features/check-network-site-count.feature
    • features/check-network-site-option-value.feature
    • features/check-network-required-plugins.feature

All passing locally.

@deshabhishek007 deshabhishek007 requested a review from a team as a code owner March 4, 2026 22:18
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the wp doctor command's diagnostic capabilities for WordPress multisite environments. It introduces new checks that allow administrators to monitor the health and compliance of their networks by validating site counts, ensuring critical network options are correctly configured, and verifying that all required plugins are active network-wide. These additions provide more robust tools for maintaining stable and well-configured multisite installations.

Highlights

  • New Multisite Checks: Introduced three new wp doctor checks specifically designed for WordPress multisite installations: Network_Site_Count, Network_Site_Option_Value, and Network_Required_Plugins.
  • Network Site Count Validation: Added a check to verify that the number of sites in a multisite network falls within configurable minimum and maximum thresholds.
  • Network Option Value Verification: Implemented a check to validate the value of network-level options using get_site_option(), supporting both expected values and values that should not be present.
  • Required Network Plugins Enforcement: Created a check to ensure that specified plugins are installed and correctly network-activated across the multisite installation.
  • PHP 8.1 Compatibility: Added a compatibility guard for ReflectionProperty::setAccessible() in src/Command.php to ensure proper functionality on PHP versions prior to 8.1.
Changelog
  • features/check-network-required-plugins.feature
    • Added Behat feature tests for the new Network_Required_Plugins check, covering scenarios for non-network-activated and network-activated plugins.
  • features/check-network-site-count.feature
    • Added Behat feature tests for the new Network_Site_Count check, including scenarios for site counts within and outside expected ranges.
  • features/check-network-site-option-value.feature
    • Added Behat feature tests for the new Network_Site_Option_Value check, covering scenarios for expected values and values that should not be present.
  • src/Check/Network_Required_Plugins.php
    • Implemented the Network_Required_Plugins class, which checks if a list of specified plugins are installed and network-activated, reporting missing or incorrectly activated plugins.
  • src/Check/Network_Site_Count.php
    • Implemented the Network_Site_Count class, which verifies if the total number of sites in a multisite network falls within a configured minimum and maximum range.
  • src/Check/Network_Site_Option_Value.php
    • Implemented the Network_Site_Option_Value class, which validates a specific network option's value against an expected value or ensures it's not a certain value.
  • src/Command.php
    • Modified the list_ method to add a conditional check for PHP_VERSION_ID < 80100 before calling ReflectionProperty::setAccessible(true) to maintain compatibility with older PHP versions.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces three useful checks for WordPress multisite installations: Network_Site_Count, Network_Site_Option_Value, and Network_Required_Plugins. The implementation is solid and includes good test coverage with Behat features. I have a few suggestions for improvement. In Network_Required_Plugins, I've recommended refactoring to use WordPress internal functions instead of WP_CLI::run_command for better performance. In Network_Site_Count, I've suggested a small refactoring to improve code clarity and consistency by casting properties in the constructor. The other changes, including the PHP 8.1 compatibility fix in Command.php, look good.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new multisite-focused wp doctor checks (with Behat coverage) to help diagnose common network-level configuration and compliance issues, plus a small PHP-version compatibility tweak in the doctor list reflection flow.

Changes:

  • Added multisite checks for network site count thresholds, network option value validation, and required network-activated plugins.
  • Added Behat feature coverage for each new multisite check.
  • Guarded ReflectionProperty::setAccessible(true) usage in doctor list for PHP version compatibility.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Command.php Adjusts reflection accessibility handling for doctor list token replacement across PHP versions.
src/Check/Network_Site_Count.php New check to warn when site count is outside configurable min/max thresholds.
src/Check/Network_Site_Option_Value.php New check to validate get_site_option() against expected / not-expected values.
src/Check/Network_Required_Plugins.php New check to ensure specified plugins are installed and network-activated.
features/check-network-site-count.feature Behat coverage for the new network site count check.
features/check-network-site-option-value.feature Behat coverage for the new network option value check.
features/check-network-required-plugins.feature Behat coverage for the new required network plugins check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants